* Construct imported input shares, export shares, material shares, and international status indicators for Mexican micro data

gen si  = matfor / mat
gen xi =  exports / salestot
bys year: egen totalmat = total(mat)
gen mi = mat / totalmat 
bys year: egen totalsales = total(salestot)
gen vi = salestot / totalsales 
gen misi = mi * si

* International status indicators
gen importer_only =0 // importer only.
replace importer=1 if si>0 & si!=. & xi==0 & xi!=.
gen exporter_only = 0 // exporter only.
replace exporter = 1 if xi>0 & xi!=. & si==0 & si!=.
gen MX = 0 // global
replace MX = 1 if xi>0 & xi!=. & si>0 & si!=.
gen importer =0
replace importer=1 if si>0 & si!=.
gen exporter = 0
replace exporter = 1 if xi>0 & xi!=.
gen MoX = 0 // either importer or exporter; i.e. exclude purely domestic firms.
replace MoX = 1 if importer==1 | exporter==1
